package com.imay.live.view.custom;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.imay.live.R;
import com.imay.live.activity.WebViewActivity;
import com.imay.live.utils.ViewUtil;

/**
 * Created by Administrator on 2017/04/17 0017.
 */

public class RechargeTitle2 extends RelativeLayout {
    TextView tv_content;
    TextView tv_title;

    public RechargeTitle2(Context context) {
        super(context);
        init(context);
    }

    public RechargeTitle2(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
        init(context);
    }

    public RechargeTitle2(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    @RequiresApi(api = 21)
    public RechargeTitle2(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context);
    }

    void init(final Context context) {
        LayoutInflater.from(context).inflate(R.layout.view_rechargetitle, this, true);
        tv_title = ViewUtil.findView(this, R.id.recharge_title);
        tv_title.setText(getResources().getString(R.string.recharge_m));
        tv_title.setTextColor(getResources().getColor(R.color.bg_window));

        tv_content = ViewUtil.findView(this, R.id.recharge_title_text);
        tv_content.setTextColor(getResources().getColor(R.color.bg_window));
//        tv_content.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
        tv_content.setSingleLine();
        tv_content.setEllipsize(TextUtils.TruncateAt.END);

        ViewUtil.findView(this, R.id.recharge_vip_image).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                WebViewActivity.startActivity(context, "", "https://m.imay.com/recharge/largevip.html");
            }
        });
    }

    public void setText(long meili) {
        if (meili <= 0) {
            tv_content.setText("0");
        } else {
            tv_content.setText(String.valueOf(meili));
        }

    }

    public void setTitleText(CharSequence text) {
        tv_title.setText(text);
    }
}
